import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', () => {
  const count = ref(0)
  const doubleCount = computed(() => count.value * 2)
  function increment() {
    count.value++
  }

  //章节
  const bookChapterList = ref<any>()
  function getChapter(obj: any) {
    bookChapterList.value = obj
  }

  //全部评论
  const bookAllCommentList = ref<any>()
  function getAllComment(obj: any) {
    bookAllCommentList.value = obj
  }

  //登录信息
  const userInfo = ref<any>()
  function getUserInfo(info: any) {
    userInfo.value = info
  }

  //保存路由来源信息
  const routerInfo = ref<any>(null)
  function changeRouterInfo(o: any) {
    routerInfo.value = o
  }





  return {
    count,
    doubleCount,
    increment,
    getChapter,
    bookChapterList,
    bookAllCommentList,
    getAllComment,
    userInfo,
    getUserInfo,
    routerInfo,
    changeRouterInfo
  }
})
